<template>
  <div class="app-container">
    <TableMapper ref="mapper" @done="handleDone" :propsEditObject="propsObject" />
  </div>
</template>
<script>

import { getDataextractionJobDetail } from '@/api/dataextractionrealtime/single.js'
import TableMapper from './components/tableMapper.vue'
export default {
  name: 'Mappers',
  components: { TableMapper },
  props: {
    propsEdit: Object,
  },
  data() {
    return {
      propsObject: {},
    }
  },
  mounth() {
    console.log(this.propsEdit, 'propsEdit-----')
  },
  watch: {
    propsEdit: {
      deep: true,
      immediate: true,
      handler: function (newVal, oldVal) {
        if (newVal) {
          console.log(newVal, 'newValnewValnewValnewValnewValnewValnewValnewVal')
          this.propsObject = newVal
        }
      },
    },
  },
  methods: {
    fun() {
      if (this.propsEdit.addroedit == 'update') {
        getDataextractionJobDetail(this.propsEdit.id).then((response) => {
          if (response.data.code === 0) {
            this.editdata = response.data.data
            this.$refs.mapper.refsFun(this.editdata)
          }
        })
      }
    },
    async handleDone(info) {
      console.log('-type----' + JSON.stringify(info))
      this.$emit('done', info)
    },
    sendTables(fromTablesList, toTablesList) {
      this.$refs.mapper.fromTablesList = fromTablesList
      this.$refs.mapper.toTablesList = toTablesList
    },
    getLTables() {
      return this.$refs.mapper.getLTables()
    },
    getRTables() {
      return this.$refs.mapper.getRTables()
    },
    getConfigForm() {
      return this.$refs.mapper.getConfigForm()
    },
    getName() {
      this.fun() 
      console.log(111111111111111111111111111);
      return this.$refs.mapper.getName()
    },
    rest() {
      this.$refs.mapper.rest()
    },
  },
}
</script>
